﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using HtmlAgilityPack;

namespace OlapProject
{
    class Log
    {
        private static RichTextBox outBox;     
    

        public static void init(RichTextBox textBox)
        {
            outBox = textBox;
        }

        public static void writeLine(string text, params object[] args)
        {
            text = string.Format(text, args);
            writeLine(text);
        }

        public static void writeLine(string text, Color color)
        {

             MethodInvoker action = delegate
             {          
                 Color current = outBox.ForeColor;
                    outBox.SelectionColor = color;
                    outBox.SelectedText = text + "\n";
                    outBox.Refresh(); 
             };
             outBox.BeginInvoke(action);       
       
           
        }

        public static void writeLine(string text)
        {
            writeLine(text, Color.Black);
        }

        public static void parserLog(int counter, string text = "")
        {
            if (counter % 5 == 0)
            {
                Log.writeLine("Parse page number = {0}", counter + " // " + text);            
            }
        }
    }
}
